package cn.yh.controller;

import cn.yh.model.User;
import cn.yh.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
//@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl service;
    @RequestMapping("/findById")
    @ResponseBody
    public ModelAndView findById(@RequestBody int id){
        User byId = service.findById(id);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("user",byId);
        System.out.println(byId);
        modelAndView.setViewName("index.jsp");

        return modelAndView;
    }

}
